using UnityEngine;
using System.Collections;

/**
 * Script of time bonus behaviour description.
 * The purpose of this class is to subtract time to player.
 * @author Benjamin Bruneau
 */
public class TimeBonusScript : MonoBehaviour 
{
	
	private const string BALL_NAME = "Ball"; // Main GameObject's name
	
	public GameObject _dataContainer; // Data container GameObject
	
	public float _timeAlterer = 5.0f;
	
	/*
	 * Called on collision(trigger).
	 * @param Collider
	 * @return void
	 */
	void OnTriggerEnter(Collider pCollider)
	{
		//If collide with the ball
		if (pCollider.gameObject.name.Equals(BALL_NAME))
		{
			// Current timer - 5 seconds
			_dataContainer.GetComponent<TimeScript>().alterTime(_timeAlterer);
			
			//Disappear
			Destroy(this.gameObject);
		}	
	}
}
